#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<long long> dp(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        int temp;
        cin >> temp;
        dp[i] = dp[i - 1] + temp;
    }
    while (t--) {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    return 0;
}